﻿
Module Iniciar
    Friend WithEvents ClienteCitra As New clsCLIENTE_CITRA

    Sub Main()
        Application.EnableVisualStyles()
        Application.SetCompatibleTextRenderingDefault(False)
        Dim Servidor As String = "" ' "201.163.91.243"
        Try

            Try

                RegVersion = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\NETSIS\\SKELETON\\Client")

                If (Not RegVersion Is Nothing) Then 'SI EXISTE LA LLAVE
                    IP_SERVER = RegVersion.GetValue("IP_SERVER")
                    ' IP_SERVER = "192.168.254.246"
                    VersionInstalada = RegVersion.GetValue("VERSION")
                    SearchUpdateHours = CInt(RegVersion.GetValue("UPDATE"))
                    SearchRequiered = CInt(RegVersion.GetValue("REQUIEREN"))
                End If
            Catch ex As Exception
                MsgBox("No se pudo acceder al registro de Windows", MsgBoxStyle.Exclamation, "Verificar permisos")
                Global.System.Windows.Forms.Application.Exit()

            End Try

            Servidor = IP_SERVER

          
            InitialConnection = "data source =" & IP_SERVER & "; initial catalog = CitraGenerales; user id = sa; password = Ausl4321OPTRA"
            CitraConnection = "data source =" & IP_SERVER & "; initial catalog = CITRA_PILESO; user id = sa; password = Ausl4321OPTRA"
            NoiConnection = "Driver=Firebird/InterBase(r) driver;User=SYSDBA;Password=masterkey;DBNAME=" & BuscarStrDatoCitra("SELECT BD_NOI FROM PARAMETROS WHERE IDPARAMETRO=1") & ";DataSource=" & IP_SERVER & "; Port=3051;Dialect=3; Charset=NONE;Role=;Connection lifetime=15;Pooling=true; MinPoolSize=0;MaxPoolSize=50;Packet Size=8192;ServerType=1;"

            'NoiConnection = "Driver={Firebird/InterBase(r) driver};SERVERNODE=COORDTI;DBNAME=" & BuscarStrDatoCitra("SELECT BD_NOI FROM PARAMETROS WHERE IDPARAMETRO=1") & ";UID=SYSDBA;PWD=masterkey;"
            RelojConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & BuscarStrDatoCitra("SELECT BD_RELOJ FROM PARAMETROS WHERE IDPARAMETRO=1") & ";"

        Catch ex As Exception
            MsgBox("No se pudo conectar con el servidor Citra", MsgBoxStyle.Information, "Citra no iniciado")
            Exit Sub

            Global.System.Windows.Forms.Application.Exit()
        End Try

        Dim login As frmLoginAeroGlass = New frmLoginAeroGlass
        BIOMETRIA_INICIADA = False


        login.ShowDialog()

        If (login.DialogResult = DialogResult.OK) Then
            FORMULARIOS.CONECTA_FORMULARIOS()
            Dim DATOS_FORM As New List(Of String)
            DATOS_FORM = Formulario(NOMBRES_FORMULARIOS.MAIN)
            FORMULARIOS.ABRE_FORMULARIO(DATOS_FORM.Item(1), DATOS_FORM.Item(1))

            BITACORA.CONECTA_BITACORA()

            Dim Principal As frmMainWindow = New frmMainWindow
            Principal.StyleManager1.ManagerStyle = DevComponents.DotNetBar.eStyle.Office2007Blue
            Principal.ShowDialog()

            If Principal.DialogResult = DialogResult.OK Then
                FORMULARIOS.CIERRA_FORMULARIO(Formulario(NOMBRES_FORMULARIOS.MAIN).Item(1))
                FORMULARIOS.DESCONECTA_FORMULARIOS()
            End If
        End If


    End Sub
End Module
